package jdbc.hr.main;

import java.util.ArrayList;
import java.util.Date;

import jdbc.hr.dao.CopyOfEmployeeDAO2;
import jdbc.hr.dao.EmployeeDAO;
import jdbc.hr.domain.Employee;

public class EmployeeTest {
	
	public static void main(String[] args) throws Exception {
	//1. DriverLoading 
		Class.forName("oracle.jdbc.driver.OracleDriver");
		EmployeeDAO dao = new EmployeeDAO();
		
		//직원 정보 insert
		//Employee emp1 = new Employee("e-50","에이스","ace@naver.com","사원",new Date(113,5,22),320000000,"d-1");
		
		//int cnt = 0;
		
		//cnt = dao.insertEmployee(emp1);
		
		//System.out.println(cnt+"명의 직원정보가 추가됨");
		
		//Employee emp2 = new Employee("e-50", "트럭","asksk@naver.com","점장",new Date(113,2,11),46546546,"d-1");
		//dao.updateEmployee(emp2);
		
		//dao.deleteEmployeeById("e-50");
		dao.deleteEmployeeByDepartmentId("d-1");
		
		System.out.println("-----------조회--------------");
		
//		Employee result = dao.selectEmployeebyId("e3");
//		if(result != null){
//			System.out.println("ID로 조회결과 : "+result);
//		}else{
//			System.out.println("등록된 직원이 없습니다.");
//		}
//		
//		int count = dao.selectTotalEmploteeCount();
//		System.out.println("총 직원수 : " + count);
//		
		Employee emp = dao.selectEmployeeByIdJoinDepartment("e9");
//		System.out.println(emp);
		System.out.println(emp.getDept().getDepartmentId());
		
		System.out.println("-------------직원정보 전체 조회-----------------");
		
		ArrayList<Employee> list = dao.selectEmployeeList();
		for(Employee e : list){
			System.out.println(e);
			System.out.println("직원 명 : 부서명 = "+e.getEmployeeName()+" : " +e.getDept().getDepartmentName());
		}
		System.out.println("---------------연봉 범위로 조회----------------");
		list = dao.selectEmployeeBySalaryRange(1000000, 300000000);
		for(Employee e : list){
			System.out.println(e);
			System.out.println("직원 명 : 부서명  = "+e.getEmployeeName()+" : " +e.getDept().getDepartmentName());
		}

		CopyOfEmployeeDAO2 aaa = CopyOfEmployeeDAO2.getInstance();

	}
}
